<template>
	<view>
		<u-navbar
			title="设置"
			:autoBack="true"
			placeholder
		>
		</u-navbar>
		<scroll-view :scroll-y="true" :style="{height: scrollViewHeight}">
			<template v-for="(cellGroup, index) in list">
				<view :key="index">
					<u-cell-group :border="false" :customStyle="{backgroundColor: '#fff'}">
						<u-cell size="large" :url="cell.url" :icon="cell.icon" :title="cell.title" isLink v-for="(cell, index1) in cellGroup" :key="index1"></u-cell>
					</u-cell-group>
					<view style="height: 32rpx;"/>
				</view>
			</template>
			<view style="height: 128rpx;"/>
			<view style="padding: 0 32rpx;">
				<u-button @click="logout" :color="appColor" text="退出"></u-button>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {logout} from '@/api/me.js';
	import {mapActions} from 'vuex';
	export default {
		data() {
			return {
				list: [
					[
						{title: '我的资料', icon: 'bookmark', url: '/pageDiamond1/me/profile'},
						{title: '隐私协议', icon: 'file-text', url: '/pageDiamond1/me/privacy'},
					]
				]
			}
		},
		computed: {
			appColor() {
				return this.appPrimaryColor
			},
			scrollViewHeight() {
				return this.scrollHeight - 44 + 'px';
			}
		},
		methods: {
			...mapActions(['setLogout']),
			logout() {
				logout().then(res => {
					this.$cuTip('退出成功');
					// 清空缓存
					uni.clearStorageSync()
					// 清空vuex
					this.setLogout()
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #f5f5f5;
	}
</style>